//
//  YDUserInfo.m
//  YDBASE
//
//  Created by wangyd on 2021/12/24.
//  Copyright © 2021 wuyezhiguhun. All rights reserved.
//

#import "YDUserInfo.h"

@interface YDUserInfo()
/** 姓 */
@property (nonatomic, copy) NSArray *surnameArray;
/** 字牌 */
@property (nonatomic, copy) NSArray *plateArray;
/** 名 */
@property (nonatomic, copy) NSArray *nameArray;

@end

static YDUserInfo *userInfo = nil;

@implementation YDUserInfo

/**
 * 单例
 */
+ (YDUserInfo *)sharedUserInfo {
    static dispatch_once_t oneToken;
    dispatch_once(&oneToken, ^{
        userInfo = [[YDUserInfo alloc] init];
    });
    return userInfo;
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone {
    if (userInfo == nil) {
        static dispatch_once_t oneToken;
        dispatch_once(&oneToken, ^{
            userInfo = [super allocWithZone:zone];
        });
    }
    return userInfo;
}

- (id)copy {
    return [YDUserInfo sharedUserInfo];
}

- (id)mutableCopy {
    return [YDUserInfo sharedUserInfo];
}

/**
 * 获取姓名
 */
- (NSString *)getUserName {
    
    NSString *surname = [self.surnameArray objectAtIndex:arc4random() % [self.surnameArray count]];
    NSString *plate = [self.plateArray objectAtIndex:arc4random() % [self.plateArray count]];
    NSString *name = [self.nameArray objectAtIndex:arc4random() % [self.nameArray count]];
    
    return [NSString stringWithFormat:@"%@%@%@", surname, plate, name];
}

/**
 * 获取年纪
 */
- (NSString *)getUserAge {
    return [NSString stringWithFormat:@"%d", arc4random() % 8 + 18];
}

#pragma mark ==== get ====
- (NSArray *)surnameArray {
    if (!_surnameArray) {
        _surnameArray = @[@"赵",@"钱",@"孙",@"李",@"周",@"吴",@"郑",@"王",@"冯",@"陈",@"褚",@"卫",@"蒋",@"沈",@"韩",@"杨",@"朱",@"秦",@"尤",@"许",@"何",@"吕",@"施",@"张",@"孔",@"曹",@"严",@"华",@"金",@"魏",@"陶",@"姜",@"戚",@"谢",@"邹",@"喻",@"柏",@"水",@"窦",@"章"];
    }
    return _surnameArray;
}

- (NSArray *)plateArray {
    if (!_plateArray) {
        _plateArray = @[@"绍",@"胜",@"文",@"明",@"广",@"成",@"新",@"允",@"治",@"忠"];
    }
    return _plateArray;
}

- (NSArray *)nameArray {
    if (!_nameArray) {
        _nameArray = @[@"天",@"地",@"玄",@"黄",@"宇",@"宙",@"洪",@"荒",@"日",@"月",@"盈",@"昃",@"辰",@"宿",@"列",@"张",@"寒",@"来",@"暑",@"往",@"秋",@"收",@"冬",@"闰",@"余",@"成",@"岁",@"律",@"吕",@"调",@"阳",@"云",@"腾",@"致",@"雨",@"露",@"结",@"为",@"霜",@"金",@"生",@"丽",@"水",@"玉",@"出",@"昆",@"冈",@"剑",@"号",@"巨",@"阙",@"珠",@"称",@"夜",@"光",@"果",@"珍",@"李",@"柰",@"菜",@"重",@"芥",@"姜",@"海",@"咸",@"河",@"淡",@"鳞",@"潜",@"羽",@"翔",@"龙",@"师",@"火",@"帝",@"鸟",@"官",@"人",@"皇",@"始",@"制",@"文",@"字",@"乃",@"服",@"衣",@"裳"];
    }
    return _nameArray;
}

@end
